Repository navigation
Reject overlapping agent returns without blocking provider callbacks - #1971
Merged
Merged
Conversation
Keep provider I/O outside coordinator bookkeeping locks, preserving retry ownership on failed return. Add two independent registered-substitute regressions that fail before and pass after on both engine targets. Co-authored-by: OpenAI Codex <codex@openai.com>
CharliePoole
approved these changes
Nov 16, 2026
CharliePoole
left a comment
Member
There was a problem hiding this comment.
Looks good and well-tested. Thanks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TestAgentService.ReturnAgentholds a per-agent ownership monitor while calling the provider. If the provider waits for a callback on another thread and that callback attempts to return the same agent, the callback cannot complete until the first return finishes. The bounded substitute-provider regressions demonstrate this interaction; this is not a report of an observed production hang in the built-in local provider.Mark the exact owned agent as returning under the short ownership-index lock, then call the originating provider without holding a bookkeeping lock. Remove ownership only after successful return. Reset the in-progress flag on failure so an explicit later retry remains possible. Current upstream
ExitMessageand exit-event forwarding are preserved.The behavior change to review explicitly is that an overlapping return now throws
InvalidOperationExceptionpromptly instead of waiting for the first provider call. A failed provider return retains ownership, and a successful return still releases exactly once.This is an independent two-file correction on main
5f1dae55. It adds no remote implementation, dependency/API-package changes, agent process code or session deployment integration.Windows validation on
net462andnet10.0:cat != Pending && cat != Acceptance).Before-failure and after-success receipts are preserved locally. No new native Linux/macOS or hardware validation is claimed; hosted CI is separate from these local results.
Draft for @CharliePoole's review. No merge is requested. Session deployment #1968 remains a separate draft pending Neil's discussion with Charlie.
Prepared jointly by Neil Colvin and OpenAI Codex.